<template>
  <div class="app-container">
    <el-table
      v-loading="loading"
      :data="scoreRows"
      row-key="term"
      style="width: 100%"
    >
      <el-table-column type="expand">
        <template slot-scope="props">
          <el-table :data="props.row.termScores" style="width: 100%">
            <el-table-column label="课程编号" prop="courseNo" align="center" />
            <el-table-column label="课程名称" prop="courseName" align="center" />
            <el-table-column label="学分" prop="stuScore" align="center" />
            <el-table-column label="成绩" prop="score" align="center" />
          </el-table>
        </template>
      </el-table-column>

      <el-table-column label="学期" prop="term" align="center" />
      <el-table-column label="课程数量" align="center">
        <template slot-scope="scope">
          {{ scope.row.termScores.length }}
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getMySemesterScores } from "@/api/student/score"; // 替换为你的接口路径

export default {
  name: "MyScoresBySemester",
  data() {
    return {
      loading: false,
      scoreRows: []
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      getMySemesterScores().then(response => {
        if (response.code === 200) {
          this.scoreRows = response.rows;
        }
        this.loading = false;
      });
    }
  }
};
</script>